using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class ExpUpgradeItem
{
    public string Key { get; set; }
    private List<string> _descriptions = new();
    public int Weight { get; set; }
    public bool IsWeapon { get; set; } = true;

    public string IconName { get; set; }

    public string Description
    {
        get
        {
            if (Level >= _descriptions.Count) return "";
            return _descriptions[Level]; 
        }
    }

    public int Level { get; set; }
    public Action<int> OnLevelUp;
    public int MaxLevel => _descriptions.Count-1;

    private List<Action> _onUpgrades = new();

    public bool IsUpgradeMaxLevel => Level > MaxLevel; // 已经最大等级了
    public bool IsUpgradeWillMaxLevel => Level == MaxLevel; // 下一级就是最高级
    public void Upgrade()
    {
        _onUpgrades[Level]?.Invoke();
        Level += 1;
        OnLevelUp?.Invoke(Level);
    }

    public ExpUpgradeItem AddOnUpgrade(string description,Action action)
    {
        _descriptions.Add(description);
        _onUpgrades.Add(action);
        return this;
    }
}
